From ab8cda3c7df0e86de498860d03c33dbd40447d6a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 11 Aug 2020 10:25:33 -0600 Subject: [PATCH] add macos qt 5.15.0 build with artifactory image. (#624) --- .travis.yml | 20 +++++-- tools/build_qt.sh | 113 +++++++++++++++++++++++++++++++++++++++ tools/travis_install_osx | 52 +++++++++++++----- 3 files changed, 169 insertions(+), 16 deletions(-) create mode 100755 tools/build_qt.sh diff --git a/.travis.yml b/.travis.yml index c2369fd99..d8c27542b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,9 @@ jobs: timeout: 600 - os: osx compiler: clang - env: QT_VERSION="5.9.9" + env: + - QT_VERSION="5.9.9" + - QT_INSTALL_METHOD="installer" cache: directories: - $HOME/Cache @@ -64,7 +66,19 @@ jobs: - os: osx osx_image: xcode10.3 compiler: clang - env: QT_VERSION="5.12.9" + env: + - QT_VERSION="5.12.9" + - QT_INSTALL_METHOD="installer" + cache: + directories: + - $HOME/Cache + timeout: 600 + - os: osx + osx_image: xcode11.6 + compiler: clang + env: + - QT_VERSION="5.15.0" + - QT_INSTALL_METHOD="artifactory" cache: directories: - $HOME/Cache @@ -84,7 +98,7 @@ jobs: install: - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "local" ]; then ./tools/travis_install_linux_local ${QT_VERSION} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis_install_osx ${QT_VERSION} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi + - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis_install_osx ${QT_VERSION} ${QT_INSTALL_METHOD} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi script: - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "coverage" ]; then ./tools/travis_script_linux_coverage; fi diff --git a/tools/build_qt.sh b/tools/build_qt.sh new file mode 100755 index 000000000..4c27c36b7 --- /dev/null +++ b/tools/build_qt.sh @@ -0,0 +1,113 @@ +#!/bin/bash -ex + +if [ $# -ne 1 ]; then + echo "$0 version" + exit 1 +fi +version=${1} +sourcetype=tar +#flavor=debug +flavor=release +#flavor=debug-and-release + +buildroot=$(pwd)/qt-${version}-${flavor}-${sourcetype} +mkdir "$buildroot" +sourcedir=${buildroot}/source +builddir=${buildroot}/build +installdir=/Users/travis/Cache/Qt +archive=qt-${version}-${flavor}-macos.tar.xz + +if [ -e "${sourcedir}" ]; then + echo "source directory \"${sourcedir}\" already exits." + exit 1 +fi +if [ -e "${builddir}" ]; then + echo "build directory \"${builddir}\" already exits." + exit 1 +fi +if [ -e "${installdir}" ]; then + echo "install directory \"${installdir}\" already exits." + exit 1 +fi + +if [ "${sourcetype}" == "git" ]; then + git clone git://code.qt.io/qt/qt5.git "${sourcedir}" +else + mkdir -p "${sourcedir}" + versionmm=$(echo "${version}" | cut -d. -f1,2) + if [ ! -e "qt-everywhere-src-${version}.tar.xz" ]; then + wget -nv "https://download.qt.io/archive/qt/${versionmm}/${version}/single/qt-everywhere-src-${version}.tar.xz" + fi + tar -x --strip-components 1 --xz --directory "${sourcedir}" --file "qt-everywhere-src-${version}.tar.xz" +fi +cd "${sourcedir}" + +# exclude modules without some kind of LGPL license. +# virtualkeyboard is pretty sticky, it gets deployed if it exists and you use Gui. +excludes=( \ +qtcharts \ +qtdatavis3d \ +qtlottie \ +qtnetworkauth \ +qtquick3d \ +qtvirtualkeyboard \ +qtwebglplugin \ +) + +# also some modules we don't use +excludes+=( \ +qtpurchasing \ +qtscript \ +) + +# other modules we don't want +# the tarballs don't include these modules, but git does +excludes+=( \ +qtqa \ +) + +if [ "${sourcetype}" == "git" ]; then + if true; then + # tagged when released + git checkout "v${version}" + else + # branch, before tagged + git checkout "${version}" + fi + modules=essential,addon,-$(echo "${excludes[@]}" | sed 's/ /,-/g') + echo "$modules" + perl init-repository --module-subset="${modules}" +else + for component in "${excludes[@]}" + do + /bin/rm -fr "${component}" + done +fi + +mkdir -p "${builddir}" +cd "${builddir}" +"${sourcedir}/configure" --prefix="${installdir}/${version}/clang_64" -opensource -confirm-license -nomake examples -nomake tests -${flavor} +make -j4 +make install + +licenses=( \ +"${sourcedir}/LICENSE.FDL" \ +"${sourcedir}/LICENSE.GPLv2" \ +"${sourcedir}/LICENSE.GPLv3" \ +"${sourcedir}/LICENSE.LGPLv21" \ +"${sourcedir}/LICENSE.LGPLv3" \ +"${sourcedir}/LICENSE.QT-LICENSE-AGREEMENT" \ +) + +mkdir "${installdir}/Licenses" +for license in "${licenses[@]}" +do + cp "${license}" "${installdir}/Licenses" +done + +tar -c -C "$(dirname ${installdir})" --xz -f "${archive}" "$(basename ${installdir})" +echo 'curl -u "${ARTIFACTORY_USER}:${ARTIFACTORY_API_KEY}" -X PUT "${ARTIFACTORY_BASE_URL}/'${archive}\" -T \"${builddir}/${archive}\" + +#iv=$(openssl rand -hex 8) +#openssl aes-256-cbc -e -md sha512 -iv $iv -in ${archive} -out ${archive}.${iv} + diff --git a/tools/travis_install_osx b/tools/travis_install_osx index 3b4fa8566..3f6677ead 100755 --- a/tools/travis_install_osx +++ b/tools/travis_install_osx @@ -5,10 +5,10 @@ #debug failed install function debug() { - cat ${CACHEDIR}/qt-${QT_VERSION}.env - find ${CACHEDIR}/Qt -maxdepth 3 -ls - cat ${CACHEDIR}/Qt/InstallationLog.txt - cat ${CACHEDIR}/Qt/components.xml + cat "${CACHEDIR}/qt-${QT_VERSION}.env" + find "${CACHEDIR}" -maxdepth 3 -ls + cat "${CACHEDIR}/Qt/InstallationLog.txt" + cat "${CACHEDIR}/Qt/components.xml" echo "$1" >&2 exit 1 } @@ -17,7 +17,8 @@ function debug() { function validate() { ( set +e - source ${CACHEDIR}/qt-${QT_VERSION}.env + # shellcheck source=/dev/null + source "${CACHEDIR}/qt-${QT_VERSION}.env" if [ "$(qmake -query QT_INSTALL_BINS)" != "${QTDIR}/bin" ]; then debug "ERROR: unexpected Qt location." fi @@ -28,7 +29,7 @@ function validate() { } QT_VERSION=${1:-5.12.2} -QT_VERSION_SHORT=${QT_VERSION//./} +METHOD=${2:-artifactory} # our expectation is that install-qt creates $QTDIR, $QTDIR/bin. CACHEDIR=${HOME}/Cache @@ -40,19 +41,44 @@ if [ -d "${QTDIR}/bin" ]; then echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches." if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then # the cache is being used. modify it to reset expiration date. - date > ${CACHEDIR}/timestamp + date > "${CACHEDIR}/timestamp" fi if [ -f "${CACHEDIR}/timestamp" ]; then echo -n "Cache timestamp: " cat "${CACHEDIR}/timestamp" fi else - rm -fr ${CACHEDIR} - mkdir -p ${CACHEDIR} - pushd ${CACHEDIR} - # install-qt creates the install at $PWD/Qt. - QT_CI_PACKAGES=qt.qt5.${QT_VERSION_SHORT}.clang_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt ${QT_VERSION} + rm -fr "${CACHEDIR}" + mkdir -p "${CACHEDIR}" + pushd "${CACHEDIR}" + + if [ "$METHOD" = "artifactory" ]; then + ( + # Do not leak keys + set +x + if [ -z "${ARTIFACTORY_API_KEY}" ]; then + echo "An untrusted build cannot load cache from artifactory." + echo "A PR from a forked repo will be an untrusted build." + echo "The cache can be loaded from a trusted build of the default branch." + echo "A PR from the original repo will be trusted, but has it's own cache." + echo "However, when that PR is merged it will build cache for the default branch." + echo "Also, the cron job should rebuild the cache for the default branch, if necessary," + echo "once that flavor of build in .travis.yml makes it into the default branch." + exit 1 + else + archive=qt-${QT_VERSION}-release-macos.tar.xz + curl -u "${ARTIFACTORY_USER}:${ARTIFACTORY_API_KEY}" "${ARTIFACTORY_BASE_URL}/${archive}" -o "/tmp/${archive}" + tar -x -J -f "/tmp/${archive}" + echo "export PATH=${CACHEDIR}/Qt/${QT_VERSION}/clang_64/bin:\$PATH" > "${CACHEDIR}/qt-${QT_VERSION}.env" + rm -f "/tmp/${archive}" + fi + ) + else + # install-qt creates the install at $PWD/Qt. + QT_VERSION_SHORT=${QT_VERSION//./} + QT_CI_PACKAGES=qt.qt5.${QT_VERSION_SHORT}.clang_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt "${QT_VERSION}" + rm "${CACHEDIR}"/qt-opensource*.dmg + fi popd validate - rm ${CACHEDIR}/qt-opensource*.dmg fi -- 2.30.2